$(document).ready(function() {
    var localisationMenu = $('div#localisationMenu div.menu-wrapper');
    var isLocalisationMenuClosed = true;
    var mouseMovingBetweenElementsTimeout = null;

    var showLocalisationMenu = function() {
        localisationMenu.show("blind", { direction: "vertical" }, 200);
        isLocalisationMenuClosed = false;
    };

    var hideLocalisationMenu = function() {
        if (!isLocalisationMenuClosed) {
            localisationMenu.hide("blind", { direction: "vertical" }, 200);
        }
        isLocalisationMenuClosed = true;
    };

    $("div#localisationMenu > a").click(function() {
        showLocalisationMenu();
        return false;
    });

    $("div#localisationMenu").hover(function() {
        clearTimeout(mouseMovingBetweenElementsTimeout);
    }, function() {
        mouseMovingBetweenElementsTimeout = setTimeout(hideLocalisationMenu, 10);
    });
});